# Maintainer: Alexey Kasatkin <alexeikasatkin@gmail.com>

_realname=luabind
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=0.9.1.144.ge414c57
pkgrel=1
pkgdesc="A library that helps you create bindings between C++ and Lua (mingw-w64)"
arch=('any')
url="https://www.rasterbar.com/products/luabind.html"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake" "git")
depends=("${MINGW_PACKAGE_PREFIX}-boost" "${MINGW_PACKAGE_PREFIX}-lua51")
options=('strip' 'staticlibs')
source=("${_realname}"::"git+https://github.com/DennisOSRM/luabind.git")
sha256sums=('SKIP')

pkgver() {
  cd "${_realname}"
  git describe --tags | sed -e 's|-|.|g' -e 's|v||g'
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd "${srcdir}/build-${MINGW_CHOST}"
  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
